<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var a = 10;
        var b = true;
        var c = null;
        var d = undefined;
        var e = 12.3;

        /* String */
        var a1 = String(a)
        var a2 = String(b)
        var a3 = String(c)
        var a4 = String(d)
        var a5 = String(e)
        console.log(a1,typeof a1);
        console.log(a2,typeof a2);
        console.log(a3,typeof a3);
        console.log(a4,typeof a4);
        console.log(a5,typeof a5);


        /* toString() null和undefined不能使用toString转换成字符串*/
        var b1 = a.toString()
        var b2 = b.toString()
        var b5 = e.toString()
        console.log(b1,typeof b1);
        console.log(b2,typeof b2);
        console.log(b5,typeof b5);


        /* + 
            如果+好的两边但凡有一边是字符串,那么结果就是字符串拼接,
            如果两边都没有字符串,那么结果为相加
        */
        console.log(a+"~~",typeof (a+""));
        console.log(b+"~~",typeof (b+""));
        console.log(c+"~~",typeof (c+""));
        console.log(d+"~~",typeof (d+""));
        console.log(e+"~~",typeof (e+""));

        console.log(false+100+"文渊");
        console.log(""+false+100+"文渊");//false100文渊
    </script>
</body>
</html>